/*    */ package com.zimbra.cs.account.callback;
/*    */ 
/*    */ import com.zimbra.common.account.Key.SignatureBy;
/*    */ import com.zimbra.common.account.SignatureUtil;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.util.StringUtil;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.AttributeCallback;
/*    */ import com.zimbra.cs.account.AttributeCallback.SingleValueMod;
/*    */ import com.zimbra.cs.account.DataSource;
/*    */ import com.zimbra.cs.account.Entry;
/*    */ import com.zimbra.cs.account.Identity;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.Signature;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class PlainTextSignature
/*    */   extends AttributeCallback
/*    */ {
/*    */   public void preModify(CallbackContext context, String attrName, Object value, Map attrsToModify, Entry entry)
/*    */     throws ServiceException
/*    */   {
/* 44 */     AttributeCallback.SingleValueMod mod = singleValueMod(attrName, value);
/* 45 */     if (mod.unsetting()) {
/*    */       return;
/*    */     }
/*    */     Account account;
/* 49 */     if ((entry instanceof Account)) {
/* 50 */       account = (Account)entry; } else { Account account;
/* 51 */       if ((entry instanceof Identity)) {
/* 52 */         account = ((Identity)entry).getAccount(); } else { Account account;
/* 53 */         if ((entry instanceof DataSource))
/* 54 */           account = ((DataSource)entry).getAccount(); else
/*    */           return;
/*    */       }
/*    */     }
/*    */     Account account;
/* 59 */     Signature sig = Provisioning.getInstance().get(account, Key.SignatureBy.id, mod.value());
/* 60 */     if (sig == null) {
/* 61 */       throw ServiceException.INVALID_REQUEST("No such signature " + mod.value() + " for account " + account.getName(), null);
/*    */     }
/*    */     
/* 64 */     String sigAttr = SignatureUtil.mimeTypeToAttrName("text/plain");
/* 65 */     String plainSig = sig.getAttr(sigAttr, null);
/* 66 */     if (StringUtil.isNullOrEmpty(plainSig)) {
/* 67 */       throw ServiceException.INVALID_REQUEST("Signature " + mod.value() + " must have plain text content", null);
/*    */     }
/*    */   }
/*    */   
/*    */   public void postModify(CallbackContext context, String attrName, Entry entry) {}
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/callback/PlainTextSignature.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */